﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Torch.FrameWork.Langeuages;
using Torch.FrameWork.Utility;


namespace Torch.WL.Web.Admin
{

    public partial class ChangePassword : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {            
            if (!IsPostBack)
            {
                btn_save.Attributes.Add("onclick", "return checksubmit()");

                #region 语言加入
                btn_save.Text = ResourceManager.GetString("ChangePassword_Btn_1");
                #endregion
            }
            
        }

        protected void btn_save_Click(object sender, EventArgs e)
        {
            if (OldPassword.Text != "" && NewPassword.Text != "" && RePassword.Text != "" && (NewPassword.Text == RePassword.Text))
            {
                Torch.WL.Business.UserLogic bll = new Torch.WL.Business.UserLogic();
                int id = SessionHelper.GetUserSession().UserID;
                if (bll.VerifyPassword(id, CryptMethod.MD5(OldPassword.Text.Trim(), 32)))
                {
                    if (bll.ChangePassword(id, CryptMethod.MD5(RePassword.Text.Trim(), 32)))
                    {
                        PageHelper.ShowMessagebox(this.Page, ResourceManager.GetString("Pub_Msg_update_true"));
                    }
                    else
                    {
                        PageHelper.ShowMessagebox(this.Page, ResourceManager.GetString("Pub_Msg_update_false"));
                    }
                }
                else
                {
                    
                    PageHelper.ShowMessagebox(this.Page, ResourceManager.GetString("ChangePassword_Msg_1"));
                }
            }
        }
    }
}
